#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

int findMaxForm(vector<string>& strs, int m, int n) {
    int dp[m+1][n+1];
    memset(dp, 0, sizeof(dp));
    for (string str : strs) {
        int count0 = count(str.begin(), str.end(), '0');
        int count1 = str.size() - count0;
        for (int i = m; i >= count0; i--) {
            for (int j = n; j >= count1; j--) {
                dp[i][j] = max(dp[i][j], dp[i-count0][j-count1] + 1);
            }
        }
    }
    return dp[m][n];
}
int main(){
    vector<string> strs = {"10", "0001", "111001", "1", "0"};
    cout << findMaxForm(strs, 5, 3) << endl;

    return 0;
}